<template>
  <div align="center">
    <p>用户名：<input type="text" v-model="from.name"></p><br>
    <p>密&emsp;码：<input type="text" v-model="from.pas"></p><br>
    <button @click="admin">管理员登录</button>&emsp;&emsp;
    <button @click="user">用户登录</button>
  </div>
</template>

<script>
import axios from 'axios'

export default {
name: "job_login",
  data(){
    return{
      from:{}
    }
  },
  methods:{
    admin(){
      axios({'url':'/admin/login','method':'post',data:this.from}).then(res=>{
        if(res.data.code==200){
          this.$toast.success('登陆成功')
          localStorage.setItem('admin_id',res.data.matter['id'])
          localStorage.setItem('admin_name',res.data.matter['name'])
        }else{
          this.$toast.fail(res.data.matter)
        }
      })
    },
    user(){
      axios({'url':'/user/login','method':'post',data:this.from}).then(res=>{
        if(res.data.code==200){
          this.$toast.success('登陆成功')
          localStorage.setItem('users_id',res.data.matter['id'])
          localStorage.setItem('users_name',res.data.matter['name'])
        }else{
          this.$toast.fail(res.data.matter)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>